package xzy.com.controller;

import java.io.Console;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import xzy.com.entity.domain.Menu;
import xzy.com.entity.vo.ResponseBean;
import xzy.com.service.MenuService;

@RestController
@RequestMapping("/menu")
public class MenuController {
	@Autowired
	private MenuService menuService;

	// 动态菜单
	@GetMapping("/boardList")
	public ResponseBean boardList() {
		Map<String, Object> map = new HashMap<>();
		List<Map<String, Object>> boardList = menuService.boardList();
		map.put("boardList", boardList);
		return new ResponseBean(HttpStatus.OK.value(), "动态菜单请求成功！", map);
	}
	
	//根据菜单id查询父级菜单
	@GetMapping("/findParMenuById")
	public ResponseBean findParMenuById(Long id) {
		List<Menu>list = menuService.findParMenuById(id);
		Map<String, Object>map = new HashMap<>();
		map.put("list", list);
		return new ResponseBean(HttpStatus.OK.value(), "查询成功！",map);
	}
}
